<?php

class YamlToBPTable
{
    private $tables;

    protected function parse($data)
    {
        foreach($data as $key => $element)
        {
            $table = new BPTable();
            $table->setName($key);
            foreach($element['columns'] as $fieldKey => $field)
            {
                $table->addField($fieldKey);
            }
            $this->tables[] = $table;
        }
    }

    public function __construct()
    {
        $data = sfYaml::load(sfConfig::get('sf_config_dir') . '/doctrine/schema.yml');
        $this->parse($data);
    }

    public function getTables()
    {
        return $this->tables;
    }
}